<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>联结查询 | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'joining-queries.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/joining-queries.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/joining-queries.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/joining-queries.html" rel="nofollow" target="_blank">../en/joining-queries.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch 权威指南 [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="query-dsl.html">查询领域特定语言(Query DSL)</a></span>
»
<span class="breadcrumb-node">联结查询</span>
</div>
<div class="navheader">
<span class="prev">
<a href="query-dsl-shape-query.html">« 形状(shape)查询</a>
</span>
<span class="next">
<a href="query-dsl-nested-query.html">嵌套(nested)查询 »</a>
</span>
</div>
<div class="chapter">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="joining-queries"></a>联结查询 (joining queries)
</h2>
</div></div></div>
<p>
在像 Elasticsearch 这样的分布式系统中执行完全 SQL 风格的联结(join)的成本是非常高的。
相反，Elasticsearch 提供了两种水平扩展的联结形式。
</p>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<a class="xref" href="query-dsl-nested-query.html" title="Nested query"><code class="literal">nested</code>(嵌套) 查询</a>
</span>
</dt>
<dd>
文档可能包含 <a class="xref" href="nested.html" title="Nested datatype"><code class="literal">nested</code></a>(嵌套) 类型的字段。

这些字段用于索引对象数组，其中每个对象都可以作为独立的文档进行查询(使用<code class="literal">nested</code>查询)。
</dd>
<dt>
<span class="term">
<a class="xref" href="query-dsl-has-child-query.html" title="Has child query"><code class="literal">has_child</code></a> 和 <a class="xref" href="query-dsl-has-parent-query.html" title="Has parent query"><code class="literal">has_parent</code></a> 查询
</span>
</dt>
<dd>
单个索引中的文档之间可以存在<a class="xref" href="parent-join.html" title="Join datatype"><code class="literal">join</code>字段关系</a>。

<code class="literal">has_child</code>查询返回其子文档与指定查询匹配的父文档，而<code class="literal">has_parent</code>查询返回其父文档与指定查询匹配的子文档。
</dd>
</dl>
</div>
<p>
另请参考<code class="literal">terms</code>查询中的<a class="xref" href="query-dsl-terms-query.html#query-dsl-terms-lookup" title="Terms lookup">词项查找机制</a>，它允许你从另一个文档中包含的值构建<code class="literal">terms</code>查询。
</p>





</div>
<div class="navfooter">
<span class="prev">
<a href="query-dsl-shape-query.html">« 形状(shape)查询</a>
</span>
<span class="next">
<a href="query-dsl-nested-query.html">嵌套(nested)查询 »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>